#ifndef FANFOU_H
#define FANFOU_H

#include <QMainWindow>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QUrl>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QBoxLayout>
#include <QByteArray>
#include <QMessageBox>
#include <QTextCodec>
#include <QMap>
#include <QtXml/QDomDocument>
#include <QList>
#include <QFile>
#include <QTextStream>
#include <iostream>
//#include <QScriptEngine>


//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
//QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));

namespace Ui {
    class Fanfou;
}

class Fanfou : public QMainWindow {
    Q_OBJECT
public:
    Fanfou(QWidget *parent = 0);
    ~Fanfou();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::Fanfou *ui;

    void login();
    QByteArray usernamePassword;
    QString urlUpdate;
    QString urlTimeline;
    QByteArray authString;
    void fetchTimeline();            //fetch timeline
    QList< QMap<QString, QString> >  analyseXML(QByteArray source);
private slots:
    void on_btnSubmit_clicked();
    void on_btnQuit_clicked();
    void sendMessage(QNetworkReply *);

    void fetchFinished(QNetworkReply *);
    void on_btnRefresh_clicked();
};

#endif // FANFOU_H
